<?php

namespace App\Dto;
//小程序端数据传输对象
use App\Enums\JwtUserTypeEnum;
use App\Models\Client\ClientUserModel;

class ClientDto extends BaseDto
{
    public static $user = null;
    public static $wechatUser = null;

    public static $agent = null;
    public static string $clientChannel;

    //设置当前登录用户信息
    public static function setUser($user)
    {
        self::$user = $user;

        return self::$user;
    }

    //获取当前登录用户信息
    public static function getUser():ClientUserModel
    {
        return self::$user;
    }

    //设置当前登录微信用户信息
    public static function setWechatUser($wechatUser)
    {
        self::$wechatUser = $wechatUser;

        return self::$wechatUser;
    }

    //获取当前登录微信用户信息
    public static function getWechatUser()
    {
        return self::$wechatUser;
    }

    //设置当前服务商信息
    public static function setAgentInfo($agent)
    {
        self::$agent = $agent;

        return self::$agent;
    }

    //获取当前服务商信息
    public static function getAgentInfo()
    {
        return self::$agent;
    }

    //获取当前登录用户id
    public static function userId()
    {
        return self::$user?->id;
    }

    public static function agentId()
    {
        $agentId = self::$agent?->id;
        $agentId = !empty($agentId) ? $agentId : 0;
        return $agentId;
    }


    public static function setPlatform(): string
    {
        return self::$platform = JwtUserTypeEnum::CLIENT_WEB_USER;;
    }

    /**
     * 设置C端用户当前使用环境 mini:小程序端 web:pc端
     * @param string $channel
     * @return string
     */
    public static function setClientChannel(string $channel): string
    {
        return self::$clientChannel = $channel;
    }

    /**
     * 获取C端用户当前使用环境 mini:小程序端 web:pc端
     * @return string
     */
    public static function getClientChannel(): string
    {
        return self::$clientChannel;
    }
}
